Skip to content

[BUG] TS2370: A rest parameter must be of an array type. #972

Open
@monaxat

Description

@monaxat

Hi! 👋

Firstly, thanks for your work on this project! 🙂

I'm trying to use animejs v4.0.0 in my Angular project.
Has got this error:

X [ERROR] TS2370: A rest parameter must be of an array type. [plugin angular-compiler]

    node_modules/animejs/types/index.d.ts:253:24:
      253 │ ...ort let linear: (...args?: (string | number)[]) => EasingFunct...
          ╵                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
"@angular/core": "^19.0.0",
"typescript": "~5.8.2"
"animejs": "^4.0.0",

tsconfig.json

{
  "compileOnSave": false,
  "compilerOptions": {
    "baseUrl": "./",
    "outDir": "./dist/out-tsc",
    "forceConsistentCasingInFileNames": true,
    "esModuleInterop": true,
    "strict": true,
    "noImplicitOverride": true,
    "noPropertyAccessFromIndexSignature": true,
    "noImplicitReturns": true,
    "noFallthroughCasesInSwitch": true,
    "sourceMap": true,
    "declaration": false,
    "experimentalDecorators": true,
    "moduleResolution": "node",
    "importHelpers": true,
    "target": "es2022",
    "module": "es2020",
    "lib": [
      "es2018",
      "es2020",
      "dom"
    ],
    "useDefineForClassFields": false
  },
  "angularCompilerOptions": {
    "enableI18nLegacyMessageIdFormat": false,
    "strictInjectionParameters": true,
    "strictInputAccessModifiers": true,
    "strictTemplates": true
  }
}

tsconfig.app.json

{
  "extends": "./tsconfig.json",
  "compilerOptions": {
    "outDir": "./out-tsc/app",
    "types": ["node"]
  },
  "files": [
    "src/main.ts",
    "src/polyfills.ts"
  ],
  "include": [
    "src/**/*.d.ts"
  ]
}

Here is the diff that solved my problem:

diff --git a/node_modules/animejs/types/index.d.ts b/node_modules/animejs/types/index.d.ts
index d00bc90..be37404 100644
--- a/node_modules/animejs/types/index.d.ts
+++ b/node_modules/animejs/types/index.d.ts
@@ -250,7 +250,7 @@ declare class Timeline extends Timer {
 declare function createTimeline(parameters?: TimelineParams): Timeline;
 type TimePosition = number | string | Function;
 declare namespace eases {
-    export let linear: (...args?: (string | number)[]) => EasingFunction;
+    export let linear: (...args: (string | number)[]) => EasingFunction;
     export let irregular: (length?: number, randomness?: number) => EasingFunction;
     export let steps: (steps?: number, fromStart?: boolean) => EasingFunction;
     export let cubicBezier: (mX1?: number, mY1?: number, mX2?: number, mY2?: number) => EasingFunction;

This issue body was partially generated by patch-package.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions